$(function () {
    var options = {
        modalName: "评论",
        url: "/render/commentManager/list",
        getInfoUrl: "/render/commentManager/get/{id}",
        updateUrl: "/render/commentManager/edit",
        removeUrl: "/render/commentManager/remove",
        createUrl: "/render/commentManager/add",
        searchUrl: "/render/commentManager/search",
        pageNumber: 1,
        pageSize: 7,
        columns: [
            {
                checkbox: true,
                formatter:checkboxMatter
            }, {
                field: 'id',
                title: 'ID',
                align: "center",
                width: '70px',
                class:"colStyle",
                sortable : true,
                formatter:paramsMatter
            }, {
                field: 'parent_id',
                title: '父类id',
                align: "center",
                width: '70px',
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'product_id',
                title: '商品id',
                align: "center",
                width: '88px',
                class:"colStyle",
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'user_id',
                title: '用户id',
                align: "center",
                width: '88px',
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'user_name',
                title: '用户名字',
                align: "center",
                width: '70px',
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'content',
                title: '内容',
                align: "center",
                width: '70px',
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'support',
                title: '点赞',
                align: "center",
                width: '70px',
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'oppose',
                title: '踩数',
                align: "center",
                width: '70px',
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'create_time',
                title: '创建时间',
                width: '88px',
                align: "center",
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'update_time',
                title: '更新时间',
                width: '88px',
                align: "center",
                sortable : true,
                cellStyle:formatTableUnit,
                formatter:paramsMatter
            }, {
                field: 'operate',
                title: '操作',
                align: "center",
                width: '88px',
                formatter: operateFormatter //自定义方法，添加操作按钮
            }
        ]
    };
    // 初始化table组件
    var table = new Table(options);
    table.init();

    //search按钮绑定查询事件
    $('#btnSearch').on('click', function () {
        var searchtext = {
            user_id: $("#search-user_id").val(),
            parent_id: $("#search-parent_id").val(),
            product_id: $("#search-product_id").val()
        };
        // console.log(""+$("#search-name").val());
        if($("#search-username").val() === ""&&$("#search-categoryId").val() === ""&&$("#search-id").val() === ""){
            postParams(options.url,options.onExpandRow,options,options.rowStyle,options.columns,null,true);
        }else {
            postParams(options.searchUrl,options.onExpandRow,options,options.rowStyle,options.columns,JSON.stringify(searchtext),false);
        }
    });

    $(".close,.btn-default").on("click",function () {
        $(".modal").css("display","");
        $(".modal").removeClass("in");
        $(".modal-backdrop").removeClass("in");
    });
});

// , {
//     field: 'user_image',
//         title: '用户头像',
//         align: "center",
//         width: '70px',
//         sortable : true,
//         cellStyle:formatTableUnit,
//         formatter:function paramsMatter(value) {
//         var span=document.createElement('span');
//         span.setAttribute('title',value);
//         var html="<img src='"+value+"' class='img-responsive img-rounded auto-shake'>";
//         span.innerHTML = html;
//         return span.outerHTML;
//     }
// }